﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LeetCodeSolutions
{
    /// <summary>
    /// 69. x 的平方根 
    /// </summary>
    class LeetCode69 : LeetCodeBase
    {
        public override void Execute()
        {
            int x = 8;
            CommonFuntions.Print(MySqrt(x));
        }

        public int MySqrt(int x)
        {
            for (int i = 0; i < x; i++)
            {
                int sqrt = i * i;
                if (sqrt < x)
                {
                    continue;
                }
                return sqrt;
            }

            return 0;
        }

        public int _MySqrt(int x)
        {
            return (int)Math.Sqrt(x);
        }
    }
}
